import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/task/process_directory_tree_entity.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_tree.dart';


ProcessDirectoryTreeEntity $ProcessDirectoryTreeEntityFromJson(Map<String, dynamic> json) {
  final ProcessDirectoryTreeEntity processDirectoryTreeEntity = ProcessDirectoryTreeEntity();
  final List<ProcessDirectoryTreeEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ProcessDirectoryTreeEntity>(e) as ProcessDirectoryTreeEntity).toList();
  if (children != null) {
    processDirectoryTreeEntity.children = children;
  }
  final String? companyCode = jsonConvert.convert<String>(json['companyCode']);
  if (companyCode != null) {
    processDirectoryTreeEntity.companyCode = companyCode;
  }
  final String? createBy = jsonConvert.convert<String>(json['createBy']);
  if (createBy != null) {
    processDirectoryTreeEntity.createBy = createBy;
  }
  final String? createById = jsonConvert.convert<String>(json['createById']);
  if (createById != null) {
    processDirectoryTreeEntity.createById = createById;
  }
  final String? createDate = jsonConvert.convert<String>(json['createDate']);
  if (createDate != null) {
    processDirectoryTreeEntity.createDate = createDate;
  }
  final String? deleted = jsonConvert.convert<String>(json['deleted']);
  if (deleted != null) {
    processDirectoryTreeEntity.deleted = deleted;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    processDirectoryTreeEntity.id = id;
  }
  final int? level = jsonConvert.convert<int>(json['level']);
  if (level != null) {
    processDirectoryTreeEntity.level = level;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    processDirectoryTreeEntity.name = name;
  }
  final String? parentId = jsonConvert.convert<String>(json['parentId']);
  if (parentId != null) {
    processDirectoryTreeEntity.parentId = parentId;
  }
  final String? path = jsonConvert.convert<String>(json['path']);
  if (path != null) {
    processDirectoryTreeEntity.path = path;
  }
  final String? updateBy = jsonConvert.convert<String>(json['updateBy']);
  if (updateBy != null) {
    processDirectoryTreeEntity.updateBy = updateBy;
  }
  final String? updateById = jsonConvert.convert<String>(json['updateById']);
  if (updateById != null) {
    processDirectoryTreeEntity.updateById = updateById;
  }
  final String? updateDate = jsonConvert.convert<String>(json['updateDate']);
  if (updateDate != null) {
    processDirectoryTreeEntity.updateDate = updateDate;
  }
  final bool? expand = jsonConvert.convert<bool>(json['expand']);
  if (expand != null) {
    processDirectoryTreeEntity.expand = expand;
  }
  return processDirectoryTreeEntity;
}

Map<String, dynamic> $ProcessDirectoryTreeEntityToJson(ProcessDirectoryTreeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['companyCode'] = entity.companyCode;
  data['createBy'] = entity.createBy;
  data['createById'] = entity.createById;
  data['createDate'] = entity.createDate;
  data['deleted'] = entity.deleted;
  data['id'] = entity.id;
  data['level'] = entity.level;
  data['name'] = entity.name;
  data['parentId'] = entity.parentId;
  data['path'] = entity.path;
  data['updateBy'] = entity.updateBy;
  data['updateById'] = entity.updateById;
  data['updateDate'] = entity.updateDate;
  data['expand'] = entity.expand;
  return data;
}

extension ProcessDirectoryTreeEntityExtension on ProcessDirectoryTreeEntity {
  ProcessDirectoryTreeEntity copyWith({
    List<ProcessDirectoryTreeEntity>? children,
    String? companyCode,
    String? createBy,
    String? createById,
    String? createDate,
    String? deleted,
    String? id,
    int? level,
    String? name,
    String? parentId,
    String? path,
    String? updateBy,
    String? updateById,
    String? updateDate,
    bool? expand,
  }) {
    return ProcessDirectoryTreeEntity()
      ..children = children ?? this.children
      ..companyCode = companyCode ?? this.companyCode
      ..createBy = createBy ?? this.createBy
      ..createById = createById ?? this.createById
      ..createDate = createDate ?? this.createDate
      ..deleted = deleted ?? this.deleted
      ..id = id ?? this.id
      ..level = level ?? this.level
      ..name = name ?? this.name
      ..parentId = parentId ?? this.parentId
      ..path = path ?? this.path
      ..updateBy = updateBy ?? this.updateBy
      ..updateById = updateById ?? this.updateById
      ..updateDate = updateDate ?? this.updateDate
      ..expand = expand ?? this.expand;
  }
}
